import { createStore } from 'vuex'
import getters from './getters'

const files = import.meta.glob('./modules/*.js', { eager: true })
// 自动导入modules下的所有模块
const modules = Object.keys(files).reduce((module, filePath) => {
  const moduleName = filePath.replace(/^\.\/modules\/([^.]+).*/, '$1')
  module[moduleName] = files[filePath].default
  return module
}, {})

const store = createStore({
  modules,
  getters,
  plugins: [],
})
export default store
